package com.example.testproj.http;

import java.util.Map;

/**
 * @des:
 * @author: 芮勤
 * @date: 2019/6/23 11:50
 * @see {@link }
 */
public class HttpRequestEntry extends HttpEntry {
    public String toSendMessage() {
        StringBuffer sb = new StringBuffer();
        sb.append(method).append(" ").append(path).append(" ").append(httpVersion).append(splitString);
        for (Map.Entry<String, String> bean :
                getHeaders()) {
            sb.append(bean.getKey()).append(":").append(bean.getValue()).append(splitString);
        }
        sb.append(splitString).append(splitString);
        return sb.toString();
    }

    public static class Builder{
        private HttpRequestEntry httpRequestEntry;

        public HttpRequestEntry builder(){
            httpRequestEntry=new HttpRequestEntry();
            httpRequestEntry.setMethod("GET");
            httpRequestEntry.setPath("");
            httpRequestEntry.setHttpVersion("HTTP/1.1");
            httpRequestEntry.addHeader("Host","");
            httpRequestEntry.addHeader("Connection","keep-alive");
            httpRequestEntry.addHeader("Accept","*/*");
            return httpRequestEntry;
        }

    }
}
